package o;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import com.huawei.appgallery.forum.base.card.bean.User;
import com.huawei.appgallery.forum.user.api.IUserFollow;
import com.huawei.appgallery.forum.user.api.IUserFollow.b;
import com.huawei.appgallery.forum.user.https.FollowUserResponse;
import com.huawei.hmf.annotation.ApiDefine;
import o.brc.e;
import o.cbb.j;

@ApiDefine(uri = IUserFollow.class)
public class cbj implements IUserFollow {
    private static b ˋ = new b() {
        public int ˏ() {
            return 8;
        }

        public int ˋ() {
            return 0;
        }
    };
    private static b ˎ = new b() {
        public int ˏ() {
            return 0;
        }

        public int ˋ() {
            return 1;
        }
    };
    private static b ˏ = new b() {
        public int ˏ() {
            return 0;
        }

        public int ˋ() {
            return 0;
        }
    };
    private static b ॱ = new b() {
        public int ˏ() {
            return -1;
        }

        public int ˋ() {
            return 0;
        }
    };

    public fjo<b> ॱ(Context context, @NonNull User user, int i) {
        return ˊ(context, user, i, false);
    }

    public fjo<b> ˊ(Context context, @NonNull User user, int i, boolean z) {
        final fjx o_fjx = new fjx();
        if (user == null) {
            o_fjx.ॱ(ॱ);
        }
        if (doo.ˊ(bqy.ˋ().ˏ())) {
            final Context context2 = context;
            final User user2 = user;
            final int i2 = i;
            ((cbh) fho.ˏ().ˋ("User").ॱ(cbh.class)).ˎ(context, 1, z).ˏ(new fjq<Boolean>(this) {
                final /* synthetic */ cbj ˎ;

                public void onComplete(fjo<Boolean> o_fjo_java_lang_Boolean) {
                    if (o_fjo_java_lang_Boolean.ˊ()) {
                        bqx.ˊ("UserFollowImpl", "user#checkPermissions success");
                        if (((Boolean) o_fjo_java_lang_Boolean.ॱ()).booleanValue()) {
                            bqx.ˏ("UserFollowImpl", "user#checkPermissions result is true");
                            this.ˎ.ˋ(context2, user2, i2, o_fjx);
                            return;
                        }
                        bqx.ˊ("UserFollowImpl", "user#checkPermissions result is false");
                        this.ˎ.ॱ(o_fjx);
                        return;
                    }
                    bqx.ˊ("UserFollowImpl", "user#checkPermissions failed");
                    this.ˎ.ॱ(o_fjx);
                }
            });
        } else {
            if (z) {
                ezn.ˊ().ˊ(context.getString(j.ͺॱ));
            } else {
                evk.ˏ(context, j.ͺॱ, 0).ˋ();
            }
            ˎ(o_fjx);
        }
        return o_fjx.ॱ();
    }

    private void ˋ(final Context context, final User user, int i, final fjx<b> o_fjx_com_huawei_appgallery_forum_user_api_IUserFollow_b) {
        cbg o_cbg = new cbg();
        o_cbg.ˋ(user.ॱ());
        if (i == 0) {
            o_cbg.ॱ();
        } else {
            o_cbg.ˎ();
        }
        ((brc) fho.ˏ().ˋ("Base").ॱ(brc.class)).ˋ(o_cbg, new e<cbg, FollowUserResponse>(this) {
            final /* synthetic */ cbj ˎ;

            public /* synthetic */ void ˋ(Object obj, Object obj2) {
                ˏ((cbg) obj, (FollowUserResponse) obj2);
            }

            public /* synthetic */ void ˏ(Object obj, Object obj2) {
                ˊ((cbg) obj, (FollowUserResponse) obj2);
            }

            public void ˊ(cbg o_cbg, FollowUserResponse followUserResponse) {
            }

            public void ˏ(cbg o_cbg, FollowUserResponse followUserResponse) {
                Object ˋ = this.ˎ.ˋ(followUserResponse);
                if (ˋ.ˏ() == 0) {
                    this.ˎ.ˏ(context, user.ॱˋ(), ˋ.ˋ());
                } else {
                    ckv.ˎ(context.getResources().getString(bse.ˏ.ॱ(followUserResponse.getRtnCode_()).ˏ()), 0);
                }
                o_fjx_com_huawei_appgallery_forum_user_api_IUserFollow_b.ॱ(ˋ);
            }
        });
    }

    private b ˋ(FollowUserResponse followUserResponse) {
        int rtnCode_ = followUserResponse.getRtnCode_();
        final int ॱ = followUserResponse.ॱ();
        if (rtnCode_ == 0) {
            return new b(this) {
                final /* synthetic */ cbj ˊ;

                public int ˏ() {
                    return 0;
                }

                public int ˋ() {
                    return ॱ;
                }
            };
        }
        if (rtnCode_ == 400020) {
            return ˎ;
        }
        if (rtnCode_ == 400019) {
            return ˏ;
        }
        return ॱ;
    }

    private void ˎ(fjx<b> o_fjx_com_huawei_appgallery_forum_user_api_IUserFollow_b) {
        o_fjx_com_huawei_appgallery_forum_user_api_IUserFollow_b.ॱ(ˋ);
    }

    private void ॱ(fjx<b> o_fjx_com_huawei_appgallery_forum_user_api_IUserFollow_b) {
        o_fjx_com_huawei_appgallery_forum_user_api_IUserFollow_b.ॱ(ॱ);
    }

    private void ˏ(Context context, String str, int i) {
        bqx.ˊ("UserFollowImpl", "notifyFollowChanged");
        if (TextUtils.isEmpty(str)) {
            bqx.ॱ("UserFollowImpl", "the uid is null, ignore");
            return;
        }
        Intent intent = new Intent();
        intent.setAction("ACTION_LOCAL_BRD_FOLLOW_CHANGED");
        intent.putExtra("EXRRA_UID", str);
        intent.putExtra("EXTRA_FOLLOW", i);
        ll.ˏ(context).ˋ(intent);
    }

    public IntentFilter ˎ() {
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("ACTION_LOCAL_BRD_FOLLOW_CHANGED");
        return intentFilter;
    }

    public String ˎ(@NonNull Intent intent) {
        if ("ACTION_LOCAL_BRD_FOLLOW_CHANGED".equals(intent.getAction())) {
            return intent.getStringExtra("EXRRA_UID");
        }
        return null;
    }

    public int ॱ(@NonNull Intent intent) {
        if ("ACTION_LOCAL_BRD_FOLLOW_CHANGED".equals(intent.getAction())) {
            return intent.getIntExtra("EXTRA_FOLLOW", 0);
        }
        return 0;
    }
}
